﻿
using System;
using System.IO;
using System.Windows.Data;
using System.Windows.Media.Imaging;
using Bankeren.Engine.Cards;
namespace BankerenWPF.Converters
{
    public class CardToBitmapImageConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                Card card = (Card)value;
                Stream stream = this.GetType().Assembly.GetManifestResourceStream("BankerenClient.Resources.Cards." + card.ShortName + ".png");
                if (stream != null)
                {
                    BitmapImage image = new BitmapImage();
                    image.BeginInit();
                    image.StreamSource = stream;
                    image.EndInit();
                    return image;
                }
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null;
        }
    }
}
